package domain;

import java.util.ArrayList;
import java.util.List;
import java_persistence.ServicesMapper;

/**
 * @author joseph simoneau <simoneau.joseph@gmail.com>
 *
 */
public class Invoice {

	private List<Services> myServices = new ArrayList<Services>();

	public Invoice() {
		super();
	}

	public List<Services> getMyServices() {
		return myServices;
	}

	public void setMyServices(List<Services> myServices) {
		this.myServices = myServices;
	}
	
	public void addService(Services s) {
		myServices.add(s);
	}

	
	/**Retrieves the services provided at an appointment from the database. 
	 * @param a The appointment in question.
	 * @param servmap retrieved from a valid, open SqlSession object.
	 */
	public void get_services(Appointment a, ServicesMapper servmap) {
		if( a.getDate()!=null && a.getPatient().getUsername()!=null ) {
			myServices = servmap.retrieve_by_appointment( a.getDate(), a.getPatient().getUsername() );			
		}
	}
	
	/**Deletes the invoice attached to a given appointment.
	 * @param a the appointment in question.
	 * @param servmap retrieved from a valid, open SqlSession object.
	 */
	public void delete_invoice(Appointment a, ServicesMapper servmap) {
		servmap.delete_invoice(a.getDate(), a.getPatient().getUsername());
	}
	
	
	
}
